<?xml version="1.0" encoding="utf-8" ?>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:com="http://java.sun.com/jsf/composite/componentes"
	xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="/templates/layout.xhtml">
	<script type="text/javascript"
		src="http://maps.google.com/maps/api/js?sensor=false"></script>

	<ui:include src="cadastro.xhtml" />
	<ui:include src="visualizacao.xhtml" />
	<ui:include src="cadastroImagem.xhtml" />
	<ui:include src="buscaParametroPorData.xhtml" />	

	<h2>
		<h:outputText value="#{appMessages['pontosColeta.titulo']}" />
	</h2>

	<h:form id="formPontosColeta">
		<p:toolbar id="tbPontosColeta" rendered="#{restrictions.cadastro}">
			<p:toolbarGroup>
				<p:commandButton
					id="cadastrar" 
					value="#{appMessages['pontosColeta.cadastrar']}"
					action="#{pontosColetaBean.cadastrarPontoColeta()}"
					oncomplete="modalCadastro.show();" 
					update=":modalCadastro" />
			</p:toolbarGroup>
		</p:toolbar>

		<p:messages id="msgsPontosColeta" />

		<p:confirmDialog
			header="#{appMessages['pontosColeta.remover.titulo']}"
			message="#{appMessages['pontosColeta.remover.mensagem']}"
			widgetVar="confirmacaoRemover" rendered="#{restrictions.cadastro}">
			<p:commandButton value="#{messages['resposta.sim']}"
				action="#{pontosColetaBean.removerPontoColeta()}"
				update="msgsPontosColeta dtPontosColeta"
				oncomplete="confirmacaoRemover.hide();" />
			<p:commandButton value="#{messages['resposta.nao']}"
				onclick="confirmacaoRemover.hide();" />
		</p:confirmDialog>

		<p:dataTable id="dtPontosColeta"
			value="#{pontosColetaBean.pontosColeta}" var="pontoColeta"
			paginator="true" paginatorAlwaysVisible="false" rows="10">

			<!-- Nome -->
			<p:column headerText="#{appMessages['pontosColeta.nome']}">
				<h:outputText value="#{pontoColeta.nome}" />
			</p:column>

			<!-- Descrição -->
			<p:column headerText="#{appMessages['pontosColeta.descricao']}">
				<h:outputText value="#{pontoColeta.descricao}" />
			</p:column>

			<!-- Ponto de referência -->
			<p:column headerText="#{appMessages['pontosColeta.pontoReferencia']}">
				<h:outputText value="#{pontoColeta.pontoReferencia}" />
			</p:column>

			<!-- Cidade -->
			<p:column headerText="#{appMessages['pontosColeta.cidade']}">
				<h:outputText value="#{pontoColeta.cidade.nome}" />
			</p:column>

			<p:column>
				<p:commandButton icon="ui-icon-search"
					title="#{appMessages['pontosColeta.visualizar']}"
					action="#{pontosColetaBean.carregarPontoColeta()}"
					oncomplete="modalVisualizacao.show();" update=":modalVisualizacao" />
				<p:commandButton icon="ui-icon-pencil"
					title="#{appMessages['pontosColeta.alterar']}"
					action="#{pontosColetaBean.carregarPontoColeta()}"
					oncomplete="modalCadastro.show();" update=":modalCadastro"
					rendered="#{restrictions.cadastro}" />

				<p:commandButton icon="ui-icon-print"
					title="Relatorio"
					action="#{amostraBuscaBean.carregarPontoColeta(pontoColeta.idPontoColeta)}"
					oncomplete="modalRelatorioParametroPorData.show();" update=":modalRelatorioParametroPorData" />
					
				<p:commandButton icon="ui-icon-close"
					title="#{appMessages['pontosColeta.remover']}"
					action="#{pontosColetaBean.carregarPontoColeta()}"
					oncomplete="confirmacaoRemover.show();"
					rendered="#{pontosColetaBean.mostrarBotaoRemover and restrictions.cadastro}" />
				<p:commandButton icon="ui-icon-image"
					action="#{pontosColetaBean.carregarPontoColeta()}"
					update=":modalCadastroImagem"
					oncomplete="modalCadastroImagem.show()"
					rendered="#{restrictions.cadastro || restrictions.cadastro}"	/>
					
			</p:column>
		</p:dataTable>
	</h:form>
</ui:composition>
</html>